<template>
  <div class="page" :class="className">
    <div class="scroll-view">
      <customHeader :middleTitle="headerTitle" @leftCallBack="goBack"/>
      <div class="page-body">
        <template v-if="className=='auth-none'">
          <div class="top">
            <i class="zhk-myqx"></i>
            <div class="title">没有权限</div>
            <div class="content">
              <p>• 请登录老板管理员账号重试；</p>
              <p>• 联系老板账号开通权限</p>
            </div>
          </div>
          <div class="btn-wrap">
            <div class="btn" @click="goBack">返回</div>
          </div>
        </template>
        <template v-if="className=='mkl-offline'">
          <div class="top sblx">
            <div class="title">设备已离线，长按M键5秒进入网络配置</div>
            <div class="content">
              <p>• 请确认手机在设备附近5米之内</p>
              <p>• 请确认设备已开机</p>
            </div>
          </div>
          <div class="btn-wrap">
            <div class="btn" @click="goBack">返回</div>
          </div>
        </template>
        <template v-if="className=='mkl-unbind'">
          <div class="top">
            <i class="zhk-pmts"></i>
            <div class="title">请参照设备屏幕提示进行操作</div>
            <div class="content">
              <p>• 请确认手机在设备附近5米之内</p>
              <p>• 请确认设备已开机</p>
            </div>
          </div>
          <div class="btn-wrap">
            <div class="btn" @click="goBack">返回</div>
          </div>
        </template>
        <!-- <template v-if="className=='mkl-timeout'">
          <div class="top">
            <i class="zhk-myqx"></i>
            <div class="title">网络连接超时</div>
            <div class="content">
              <p>• 请确认手机在设备附近5米之内</p>
              <p>• 请确认设备已开机</p>
            </div>
          </div>
          <div class="btn-wrap">
            <div class="btn" @click="goBack">返回重试</div>
          </div>
        </template>-->
        <template v-if="className=='mkl-unopen'">
          <div class="top">
            <i class="zhk-zwktmdsk"></i>
            <div class="title">该门店暂未开通收款功能</div>
            <div class="content">
              <p>• 立即为该门店开通收款功能</p>
              <p>• 或在主设置面板页解绑设备重新绑定可用门店</p>
            </div>
          </div>
          <div class="btn-wrap">
            <div class="btn" @click="openWxAccount">立即开通</div>
          </div>
          <div class="ignore" @click="goMainSettings">跳过，稍后开通</div>
        </template>
      </div>
    </div>
  </div>
</template>

<script>
import Vue from "vue";
import customHeader from "../../components/header/header";
import localStorageClient from "../../js/localstorage.js";
import jsBridge from "../../tools/jsBridge.js";
export default {
  name: "authNone",
  data() {
    return {
      type: "",
      className: "",
      shopId: "",
      openPayStatus: "",
      sn:""
    };
  },
  methods: {
    goBack() {
      if (this.className == "mkl-unopen") {
        //this.$router.push({ path: "/" });
         jsBridge.closeWindow();
        return;
      }
       if(String(this.$route.query.close) == 'true'){
            jsBridge.closeWindow();
          }else{
            this.$router.back();
          }
    },
    //跳转到设备主设置面板
    goMainSettings() {
      this.$router.push({path:"/qrCodeSound/mainSettings",query:{sn:this.sn,type:this.type,shopId:this.shopId}});
    },
    //跳转微信收款帐户进件
    ToWxAccount() {
      // //商户入驻状态(0:未开通,1:已开通,2:已冻结),3申请中 4已关闭 5开通失败'
      // let cache = localStorageClient.takeOutParamObject() || {};
      // cache.shopId = shopId;
      // cache.type = "1"; //新增
      // localStorageClient.injectParamObject(cache);

      // const smsCache = localStorageClient.load("sms", 120);
      // if (smsCache) {
      //   location.href =
      //     "../html/weixin_open_step1_wangshang.html?" + APP.urlParam;
      // } else {
      //   cache.dispatchPage = "weixin_open_step1_wangshang.html";
      //   cache.dispatchData = { type: "1", shopId: shopId };
      //   localStorageClient.injectParamObject(cache);
      //   this.$router.push({
      //     path: "/SMSVerification",
      //     query: CommonUtil.concatSessionId({})
      //   });
      // }
      const smsCache = localStorageClient.load("sms", 120); //data.merchantStatus == constants.store.WEIXIN_PAY_STATUS.none
      if (smsCache) {
        this.$router.push({
          path: "/storeManage/openShroffAccount",
          query: { shopId: this.shopId }
        });
      } else {
        this.$router.push({
          path: "/SMSVerification",
          query: { nextPath: "/storeManage/openShroffAccount", shopId: this.shopId }
        });
      }
    },
    openWxAccount() {
      this.ToWxAccount();
    }
  },
  computed: {
    headerTitle() {
      return  window.CommonUtil.getMachineNameByType(this.type);
    }
  },
  created() {
    this.type = this.$route.query.type; //设备类型
    this.className = this.$route.query.className; //页面类型
    this.shopId = this.$route.query.shopId;
    this.sn = this.$route.query.sn;
  },
  components: {
    customHeader
  }
};
</script>
<style lang="scss" scoped>
@import "qrCodeSound";
</style>
